<?php

namespace app\common\controller;

/**
 * 我的检查类
 * Trait MyCheck
 * @package app\common\controller
 */
trait TyCheck
{
    /**
     * 检查用户端token
     * @param $params
     * @return mixed
     */
    public function check_user_token($params)
    {
        if (!isset($params['token']) || empty($params['token'])) {
            return $this->b_logic->get_response(-1, '网络超时，请重新进入');
        }
        $token = $params['token'];
        session(['id' => $token]);
        $r_openid = session('?openid');
        if ($r_openid) {
            return $this->b_logic->get_response(1, 'OK');
        }
        return $this->b_logic->get_response(-1, '网络超时，请重新进入');
    }

    /**
     * 检查控制端token
     * @param $params
     * @return mixed
     */
    public function check_admin_token($params)
    {
        if (!isset($params['token']) || empty($params['token'])) {
            return $this->b_logic->get_response(-1, '网络超时，请重新进入');
        }
        $token = $params['token'];
        session(['id' => $token]);
        $r = session('?admin_openid');
        if ($r) {
            return $this->b_logic->get_response(1, 'OK');
        }
        return $this->b_logic->get_response(-1, '网络超时，请重新进入');
    }
}
